#ifndef KERNEL_HAL_x86_CPU_H
#define KERNEL_HAL_x86_CPU_H

namespace x86
{
	typedef struct Registers Registers;
	typedef struct DescriptorTable_Pointer DescriptorTable_Pointer;
	
	struct Registers
	{
		uint32	SS;
		uint32	GS;
		uint32	FS;
		uint32	ES;
		uint32	DS;
		uint32	EDI;
		uint32	ESI;
		uint32	EBP;
		uint32	ESP;
		uint32	EBX;
		uint32	EDX;
		uint32	ECX;
		uint32	EAX;
		uint32	Interrupt;
		uint32	Error;
		uint32	EIP;
		uint32	CS;
		uint32	EFlags;
	} _PACKED;
	
	struct DescriptorTable_Pointer
	{
		uint16	Size;
		uint32	Address;
	} _PACKED;
	
	extern "C"
	{
		void CPU_SaveContext( Registers * registers, int unwind );
		void CPU_ContextSwitch( Registers * registers );
		
		void IO_Out8( uint16 port, uint8 value );
		void IO_Out16( uint16 port, uint16 value );
		void IO_Out32( uint16 port, uint32 value );
		void IO_OutArray8( uint16 port, uint8 * data, Size size );
		void IO_OutArray16( uint16 port, uint16 * data, Size size );
		void IO_OutArray32( uint16 port, uint32 * data, Size size );
		uint8 IO_In8( uint16 port );
		uint16 IO_In16( uint16 port );
		uint32 IO_In32( uint16 port );
		void IO_Delay( void );

	}
}

#endif // KERNEL_HAL_x86_CPU_H
